package com.linln.modules.store.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.linln.common.enums.DayEnum;
import com.linln.common.enums.StatusEnum;
import com.linln.common.utils.StatusUtil;
import com.linln.modules.member.domain.MemberInfo;
import com.linln.modules.system.domain.User;

import lombok.Data;

/**
 * @author hct
 * @date 2019/09/12
 */
@Data
@Entity
@Table(name="storeinfo")
@EntityListeners(AuditingEntityListener.class)
@Where(clause = StatusUtil.NOT_DELETE)
public class Storeinfo implements Serializable {
    // 主键ID
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;
    // 商家名称
    private String store_name;
    // 商家电话
    private String store_tel;
    
    //申请用户
    //private Long memberId;
    @ManyToOne(fetch=FetchType.LAZY)
    @NotFound(action=NotFoundAction.IGNORE)
    @JoinColumn(name="member_id")   
    private MemberInfo member;
    //联系人姓名
    private String pushName;
      
    // 商家地址
    private String address;
    // 营业开始时间
    private String yingye_time;
     
  // 转发数
    private Integer sharenum;
 // 访问数
    private Integer readnum;
 // 收藏数
    private Integer collectnum;
  //点赞数  
    private Integer zannum;
   //星级 12345
    private Integer store_star; 
    //评论数
    private Integer commentnum;
    
    private String orderId;
    private String orderCode;

    // 营业执照
    private String yyzz_img;
    // 营业执照编码
    private String yyzz_code;
    // 身份证
    private String sfz_img;
    // logo
    private String logo;
    // 商家图片
    private String store_img;
    // 一级分类
    //private Long storetype_id;
    @ManyToOne(fetch=FetchType.LAZY)
    @NotFound(action=NotFoundAction.IGNORE)
    @JoinColumn(name="storetype_id")
    private Type storetype;
      
    // 二级分类
   // private Long storetype2_id;
    // 入驻期限
   // private String store_deadline;
    // 是否置顶
    private Integer istop;
    // 所属区域
    private String area;    
    @Transient
    private String areaname;  
    
    private String city;
    // 排序
    private Integer num;
    // 商家介绍
    private String details;
    
    // 创建时间
    @CreatedDate
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createDate;
    // 更新时间
    @LastModifiedDate
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateDate;
    
    // 期限选择        1=7天/2=半个月/3=一个月/4=1季度/5=半年/6=1年
    private Integer day;
    //广告时长内容
    @Transient
    private String dayValue;
    
    public String getDayValue() {
		return DayEnum.getVal(day); 
	}
    //开始时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date startTime;
    // 时长选择
    private Integer deadline;  //1=20分钟 /2=30分钟
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
   	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date endTime;
    //支付费用
    private Double fee;
    
    //支付状态  0是代付款待审核 1是已付款待审核  2 已拒绝已退款
    private Integer payStatus;    
    //0待审核 1已通过 2已拒绝
    private  Integer storeStatus;    
   
    //代理商Id
    private Long agentId;
    //代理商审核时间
    private Date shenheTime;
    
    
    // 创建者
    @CreatedBy
    @ManyToOne(fetch=FetchType.LAZY)
    @NotFound(action=NotFoundAction.IGNORE)
    @JoinColumn(name="create_by")
    @JsonIgnore
    private User createBy;
    // 更新者
    @LastModifiedBy
    @ManyToOne(fetch=FetchType.LAZY)
    @NotFound(action=NotFoundAction.IGNORE)
    @JoinColumn(name="update_by")
    @JsonIgnore
    private User updateBy;
    // 数据状态
    private Byte status = StatusEnum.OK.getCode();
}